$.fn.floadAdd = function (options) {
    var defaultOpts = {
        location: "left",//left right
        container: $("body")
    };
    this.css({
        "position": "fixed",
        "z-index": "99999",
        "top": 0
    });

    this.css(options.location, 0);
    debugger;

    var $dom = this;

    var calculatePosition = function () {
        var docScrollTop = document.documentElement.scrollTop;
        var docClientHeight = document.documentElement.clientHeight;
        var domHeight = $dom.height();
        var domTop = (docClientHeight - domHeight) / 2;
        var start = domTop + (100 * (Math.random() > 0.5 ? 1 : -1));
        $dom.animate({ "top": start + "px" });
        $dom.animate({ "top": domTop + "px" });
    }

    var run = function () {
        setInterval(function () {
            calculatePosition($dom);
        }, 100);
    }

    run();
}

// ----- call -----

$(".img-add-left").floadAdd({
    location: "left"
})

$(".img-add-right").floadAdd({
    location: "right"
})